<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>传智健康</title>
    <meta name="description" content="传智健康">
    <meta name="keywords" content="传智健康">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="../css/style.css">
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <!--<link rel="stylesheet" href="../plugins/elementui/index.css">-->
    <script src="../plugins/echarts/echarts.js"></script>

    <!-- 引入组件库 -->
    <script src="../js/vue.js"></script>
    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <!--<script src="../plugins/elementui/index.js"></script>-->
    <script src="../js/axios-0.18.0.js"></script>
</head>
<body class="hold-transition">
<div id="app">
    <!--统计分析-->
    <div class="content-header">
        <h1>统计分析
            <small>会员数量</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>统计分析</el-breadcrumb-item>
            <el-breadcrumb-item>会员数量</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <!--选择日期范围-->
    <div class="block">
        <span class="demonstration"><h2>选择日期范围</h2></span>
        <el-date-picker
                v-model="value1"
                type="monthrange"
                range-separator="至"
                start-placeholder="开始月份"
                end-placeholder="结束月份">
        </el-date-picker>
        <span slot="footer" class="dialog-footer">
                    <el-button type="primary" @click="findMember()">确定</el-button>
                </span>
    </div>
    <!--统计分析图表-->
    <div class="app-container">
        <div class="box">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart1" style="height:600px;"></div>
        </div>
    </div>

    <!--男女比例占比-->
    <div class="content-header">
        <h1>男女比例分析
            <small>男女占比</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>男女比例分析</el-breadcrumb-item>
            <el-breadcrumb-item>男女占比</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <!--男女比例图表-->
    <div class="app-container">
        <div class="box">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart2" style="height:600px;"></div>
        </div>
    </div>
    <!--年龄比例图标-->
    <div class="content-header">
        <h1>统计分析
            <small>年龄占比</small>
        </h1>
        <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb">
            <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>不同年龄段占比分析</el-breadcrumb-item>
            <el-breadcrumb-item>年龄占比</el-breadcrumb-item>
        </el-breadcrumb>
    </div>
    <!--年龄比例图表-->
    <div class="app-container">
        <div class="box">
            <!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
            <div id="chart3" style="height:600px;"></div>
        </div>
    </div>
</div>
</div>
</body>
<!-- 引入组件库 -->
<script>
    new Vue({
        el: "#app",
        data: {
            /*pickerOptions: {},*/
            value1: 'aaa'
        },
        methods: {
            //查询会员
            findMember() {
                this.showMember();
            },
            //发送统计请求
            showMember() {
                //alert(this.value1);
                // 基于准备好的dom，初始化echarts实例
                var myChart1 = echarts.init(document.getElementById('chart1'));
                axios.get("/report/getMemberReport.do?date=" + this.value1).then((res) => {
                    myChart1.setOption(
                        {
                            title: {
                                text: '会员数量'
                            },
                            tooltip: {},
                            legend: {
                                data: ['会员数量']
                            },
                            xAxis: {
                                data: res.data.data.months
                                //data: ["2019.01","2019.02","2019.03","2019.04",]
                            },
                            yAxis: {
                                type: 'value'
                            },
                            series: [{
                                name: '会员数量',
                                type: 'line',
                                data: res.data.data.memberCount
                                //data: [5, 20, 1000000, 10]
                            }]
                        });
                })
            },
            //发送男女比例请求
            showGender() {
                // 基于准备好的dom，初始化echarts实例
                var myChart2 = echarts.init(document.getElementById('chart2'));

                // 使用刚指定的配置项和数据显示图表。
                //myChart.setOption(option);

                axios.get("/report/getGenderReport.do").then((res) => {
                    myChart2.setOption({
                        title: {
                            text: '会员男女比例占比',
                            subtext: '',
                            x: 'center'
                        },
                        tooltip: {//提示框组件
                            trigger: 'item',//触发类型，在饼形图中为item
                            formatter: "{a} <br/>{b} : {c} ({d}%)"//提示内容格式
                        },
                        legend: {
                            orient: 'vertical',
                            left: 'left',
                            data: res.data.data.genderNames
                        },
                        series: [
                            {
                                name: '男女比例占比',
                                type: 'pie',
                                radius: '55%',
                                center: ['50%', '60%'],
                                data: res.data.data.genderCount,
                                itemStyle: {
                                    emphasis: {
                                        shadowBlur: 10,
                                        shadowOffsetX: 0,
                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                    }
                                }
                            }
                        ]
                    });
                });
            },
            //发送年龄比例请求按照会员的年龄段（可以指定几个年龄段，例如0-18、18-30、30-45、45以上）来展示各个年龄段的占比，通过饼形图来展示
            showAge() {
                // 基于准备好的dom，初始化echarts实例
                var myChart3 = echarts.init(document.getElementById('chart3'));

                // 使用刚指定的配置项和数据显示图表。
                //myChart.setOption(option);

                axios.get("/report/getAgeReport.do").then((res) => {
                    myChart3.setOption({
                        title: {
                            text: '不同年龄段占比',
                            subtext: '',
                            x: 'center'
                        },
                        tooltip: {//提示框组件
                            trigger: 'item',//触发类型，在饼形图中为item
                            formatter: "{a} <br/>{b} : {c} ({d}%)"//提示内容格式
                        },
                        legend: {
                            orient: 'vertical',
                            left: 'left',
                            data: res.data.data.ageNames
                        },
                        series: [
                            {
                                name: '不同年龄段占比',
                                type: 'pie',
                                radius: '55%',
                                center: ['50%', '60%'],
                                data: res.data.data.ageCount,
                                itemStyle: {
                                    emphasis: {
                                        shadowBlur: 10,
                                        shadowOffsetX: 0,
                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                    }
                                }
                            }
                        ]
                    });
                });
            }
        },
        mounted() {
            //页面加载完成加载曲线图
            this.showMember();
            //页面加载完成男女比例图
            this.showGender();
            //页面加载完成年龄比例图
            this.showAge();

        }
    })
</script>
</html>
